What it does
When Ditto uses Transform, it copies the target's types, ability, calculated stats (not HP), and all four moves — each with 5 PP. For the rest of the battle, Ditto becomes that Pokémon until it switches out or faints.
A few mechanics worth knowing: held items are not copied. Speed nature still applies, but the base Speed value is replaced by the target's — copy a fast Pokémon and you get faster, copy a slow one and you slow down. PP is limited to 5 per move, so you can't outlast an opponent trying to stall.
Transform is Ditto's action for that turn. On the following turn, Ditto selects from the 4 copied moves (each at 5 PP). One exception: if Ditto holds a Choice item, it is immediately locked to one of those copied moves after transforming.
Who runs it
Ditto is the only Pokémon that learns this move. 100% of Ditto sets run it because it has nothing else — Transform is the whole point.
Ditto's base stats average 48 across the board. Left to its own devices, it's not a threat. Its entire value comes from the question: 'What's the opponent's most threatening Pokémon, and can I copy it?' If the answer is yes, Ditto becomes that threat and the opponent has to deal with a mirror version of their own win condition.
How to use it
Bring Ditto against whichever Pokémon is hardest to answer. A fully set-up sweeper, a Pokémon that just got Tailwind started, something with a dominant ability like Intimidate — these are the copy targets worth the slot.
In doubles, Ditto needs protection. It copies on the same turn it acts, but it acts at its own Speed before the transformation buffs kick in. A partner running Follow Me or Rage Powder can absorb incoming attacks for a turn and let Ditto land the copy safely.
Remember: the copy resets when Ditto switches out. If you need it back, it has to use Transform again next time in.
Tips & strategy
Choice Scarf is the most common item. After transforming, the Scarf immediately locks Ditto to one of the copied moves, and that move hits at 1.5x damage — plus the Speed boost on top of copying the target's already-high base Speed. Against slow targets, the Scarf is less useful since you're already fast enough.
One thing that's easy to forget: Transform cannot be replicated by Copycat, and Encore cannot force you to repeat it. Those particular mind games don't work on Ditto.