It is safe and common to keep two male guinea pigs together in one cage or pen. Guinea pigs enjoy companionship as they live together in herds in the wild.
If the two guinea pigs are not purchased at the same time, it is important to quarantine the new guinea pig until the original guinea pig adapts or becomes used to the idea of having a companion. This can also prevent an illness from being transferred to the original guinea pig.
It is also very important to determine the sex of the guinea pigs before placing them in a pen together. This will prevent against any unwanted pregnancies in the future.