Portuguese comes from Latin, it’s the result of a mix of Latin (brought by the Roman Empire) and local languages like Celtic and Arabian and Iberian. Spanish, French, Italian, also originated from Latin mixing with languages spoken in each smaller region.
Portugal is an old country, it was founded before Spain was, in 1143. It originated from a county into a kingdom and had to fight the Kingdom of Castilla and Leon for it’s independence.
Castilla then managed to subjugate all other weaker kingdoms into the mess they now call Spain
Maybe it’s best if you google it, might have a more unbiased view of it.