I don't know how or when it happened and the rim is aluminium. Could this be welded or do I need to replace the rim? Can I drive the car with this rim on?
It takes skill to make a GOOD weld in aluminum and it is very complicated ( expensive) to heat-treat an aluminum weld to bring the strength back to the same as the wheel , if possible at all. Routine welds in aluminum are low strength, not that some shop might say "sure we weld aluminum". It would be cheaper to buy a whole set of rims than to get a good weld.
It can be repaired, but I would seek a professional. Refer to this instructibles article to get an idea of the work involved. https://www.instructables.com/id/How-to-Repair-a-Cracked-Alloy-Wheel/