Thinly slice the red onion into 1/8-inch slices. Peel the garlic. Place the onion and garlic in a large glass or ceramic bowl.
Add the sugar, salt, and peppercorns to a small sauce pot. Add the vinegar and stir until the sugar and salt are dissolved. Place a lid on the pot and bring the mixture up to a boil over medium-high heat.
When it reaches a boil, pour the vinegar over the sliced onion and garlic.** Press the onion down so all the pieces are submerged, then let the mixture cool to room temperature. I sometimes place a piece of plastic wrap over the onions to help push and hold them below the surface of the brine (see step by step photos below).
Once cool, use the onions immediately or transfer the onions and all the brine to a covered non-reactive container (glass, ceramic, or plastic) for storage in the refrigerator. The onions can be stored in the refrigerator for 3-4 weeks.
*You can use different kinds of vinegar to change the flavor. I suggest not using vinegar with strong flavors so they don't overpower the onions or the other ingredients. Try rice vinegar, white wine vinegar, red wine vinegar, or apple cider vinegar!***For onions that remain crunchy, pour the boiling vinegar over the onions in the bowl. If you prefer soft onions, add the onion and garlic to the sauce pot and allow them to boil in the vinegar for 1-2 minutes before transferring to a non-metal bowl to cool.