In most core Pokémon games, a Pokémon's happiness (officially "friendship" since Generation II) rises when the Pokémon gains levels, walks with you in games that support walking partners, is fed certain items, or is groomed—while fainting, using bitter herbs, and being traded reset or lower it—but the exact triggers, caps, and values differ by generation and by title, so no single list applies to every game. The question as written is incomplete ("when it..."), so the short answer is that happiness increases under several distinct conditions, and which conditions count depends entirely on which game and generation you mean.
First, clear up the terminology
The stat is called friendship in the games' internal data and in most official documentation; players usually call it happiness. It is a hidden value, separate from affection (introduced more prominently in Generation VI's Pokémon-Amie and continued in Pokémon Camp and picnics). Friendship and affection are tracked differently even when they feel similar in play. The core friendship scale runs from 0 to 255, with most evolution-by-friendship checks requiring 220 or higher at the moment of level-up (with some game-specific exceptions). That baseline is stable across the modern core series; the ways to move the number are not.
The reliable, cross-generation increases
A few actions raise friendship in essentially every game that has the mechanic:
Leveling up. Gaining a level adds friendship in the main series, typically a modest amount per level (commonly cited as +2 to +3 depending on generation), and the gain is sometimes larger when the level-up happens in the overworld rather than in a battle in games with both modes. Walking. In games with a walking partner feature—HeartGold/SoulSilver's Pokémon following you, and later Let's Go, Sword/Shield's camping-adjacent walking, Brilliant Diamond/Shining Pearl's following Pokémon, and Scarlet/Violet's picnics—steps accumulate friendship. The rate is tied to distance and to the Pokémon's current friendship band. Vitamins and EV-reducing berries. Feeding a Pokémon a vitamin (Protein, Carbos, etc.) or a friendship-raising berry (Pomeg, Kelpsy, Qualot, Hondew, Grepa, Tamato) raises friendship. The EV-reducing berries raise friendship specifically because they lower EVs, which is their designed trade-off. Grooming and massages. The haircut brothers in Gold/Silver/Crystal, the massage in various games, and similar NPC services add friendship once per day or per interaction. Holding a Soothe Bell. The Soothe Bell multiplies friendship gains; it does not generate friendship on its own. This is a common point of confusion—players sometimes expect the bell to tick friendship up passively, and it does not.
What lowers or resets it
Fainting lowers friendship, and repeated fainting can meaningfully delay a friendship evolution. Feeding bitter herbs (Heal Powder, Energy Powder, Energy Root, Revival Herb) lowers friendship because the Pokémon dislikes the taste. Trading a Pokémon resets its friendship to its species' base value, which is why a traded Pokémon often evolves by friendship more slowly. Using a Pokémon in ways that cause it to faint repeatedly—or leaving it at low HP—works against you. In some games, releasing a Pokémon or certain NPC interactions can also affect the value, though these are edge cases.
Where the question becomes genuinely ambiguous
"Does a Pokémon's happiness increase when it..." can be completed in dozens of ways, and the answer flips depending on the completion. Consider these contrasts, which are the ones players most often get wrong:
"When it is in the party but not used?" Generally no passive gain in most games, except where a game has a specific passive mechanic (for example, some titles grant friendship from walking while the Pokémon is in the party). Sitting in the PC box does not raise friendship.
"When it holds a Soothe Bell?" No, the bell only amplifies gains from actions that already raise friendship. It is a multiplier, not a source.
"When it uses a move it likes?" Not in the core friendship system. Move preferences and natures affect affection and battle behavior in some titles, but not the friendship stat directly.
"When it wins a battle?" Winning itself is not the trigger; gaining experience and leveling up is. A Pokémon that participates but does not level up typically does not gain friendship from the battle alone.
"When it is fed a Poffin or Pokéblock?" In the generations where those exist, they primarily raise Contest stats and, in some titles, affection; friendship effects vary and should not be assumed.
"When it is traded to you?" The opposite—trading resets friendship to the species base, so a freshly traded Pokémon starts low regardless of how happy it was with its previous trainer.
The mechanic is generation-specific, and that matters
The friendship system has been revised repeatedly, so a guide written for one game can mislead in another. A few concrete distinctions:
Generation II introduced friendship and the friendship-based evolutions (Eevee into Espeon/Umbreon, Golbat into Crobat, etc.). The haircut brothers and the Soothe Bell were part of this original design. Generation III added the EV-reducing berries' friendship effect and refined the Soothe Bell. Generation IV added walking-partner friendship in HeartGold/SoulSilver and expanded grooming options. Generation VI onward introduced affection as a separate axis through Pokémon-Amie, then Camp (Sword/Shield), then picnics (Scarlet/Violet). Affection can produce battle benefits (extra dodges, surviving at 1 HP, critical hits) that players often attribute to friendship, but the two values are tracked separately. Let's Go Pikachu/Eevee and Legends: Arceus bend the usual rules: Legends: Arceus in particular changed how friendship and evolution interact and is not a reliable guide for Scarlet/Violet.
This is the single biggest source of confusion in the query. A player asking "does happiness increase when it walks with me" is asking a question whose answer is yes in HeartGold/SoulSilver, Brilliant Diamond/Shining Pearl, and Scarlet/Violet picnics, but the rate and the cap differ, and in games without a walking feature the question does not apply at all.
A concrete worked example
Suppose you have a level 20 Eevee you want to evolve into Espeon (friendship ≥ 220, level up during the day in most games). You hatch it, so it starts at base friendship (often 70 for Eevee). You:
1: Give it a Soothe Bell (amplifies gains). 2: Walk 5,000 steps with it in the party in a game with walking partners. 3: Feed it ten EV-reducing berries over time. 4: Let it gain several levels in normal battles, avoiding fainting.
Each of those actions raises friendship by amounts that the game does not display. You cannot see the number without an external check or an in-game friendship rater (the friendship checker NPC, the friendship checker app in some titles, or the "friendship" display in the summary in recent games). The practical lesson: friendship is invisible, cumulative, and slow, and the actions that raise it are mostly deliberate rather than automatic. That is why the honest answer to "does it increase when it..." is "yes, for specific actions, and you usually cannot confirm the gain without a checker."
What the query leaves unknown
The question as typed is truncated after "when it," so the specific condition is missing. Without knowing (a) the game and generation and (b) the action being asked about, the only fully accurate answer is the conditional one given in the first sentence. If you can name the game and the action—for example, "Does friendship increase when it walks with me in Sword/Shield?" or "when it holds a Soothe Bell?"—the answer becomes precise, because the trigger list, the multiplier, and the cap are all game-specific. The general principle—deliberate care raises friendship, neglect and fainting lower it, and the Soothe Bell only amplifies—holds across the core series, but the numbers do not.