Rats are incredibly social! Your rat requires a ton of companionship to be happy, and a solitary rat will develop psychological and physical health problems. It’s best to keep them with other rats of the same sex… pairs can work fine, but I recommend three if you have the space and money to care for them. They form complex interpersonal dynamics and hierarchies that you can observe.
If you want a solitary rodent pet, hamsters should always be kept singly, and can be kept in smaller enclosures than rats.
Keep in mind that a proper enclosure for a group of rats, even just a trio, should be /way/ bigger than most people think. You want something chest-of-drawers sized and packed with toys.
Don’t get me wrong, rats can be great pets, they just need companions and a big enclosure.