I noticed information about these traits is somewhat sparse, so I did some testing to find out details.
Shy and Loner give small, free, constant mood bonuses most useful early in the game. The bonus depends on sims within a distance of about ~5 tiles, including through walls, floors, and rabbitholes.
Shy- +10 mood near 2 or more sims of 40 relationship or higher (friends or romantic interests).
- -10 mood near 2 or more sims below 40 relationship.
- Autonomously goes to bedroom.
- Harder to socialize.
- Requires Late Night.
- Includes never-nude trait (cannot skinny-dip). This mainly blocks the +25 "Exhilarated" moodlet of Late Night hot tubs.
Loner- +15 mood near 0 other sims (any relationship status).
- -15 mood near 2 or more sims (any status).
- Autonomously goes to bedroom.
- Harder to socialize.
- Cannot stay in groups of size 3 or larger. I rarely need to form groups of this size.
- Slower social decay. The social motive is easy to maintain, so I do not find this bonus particularly helpful.
Shy is good for stay-at-home types if we intend to have a household of size 3+ early in the game. Loner is good if we will remain solo for most of our life, or intend to avoid the mid-life-crisis reward (some challenges restrict that). Neither trait is advisable if we start a game with a household of size 2.
I believe other early mood bonuses are better than Loner/Shy for stay-at-home sims, like Loves the Outdoors, Couch Potato, Over-Emotional, etc. These have more easily managed downsides than Shy and Loner. All these passive bonuses become less important later in the game as we unlock better sources of happiness (food, decorations, music, etc), so Shy and Loner are not good traits for second-generation sims, except for personality flavor.