The purpose was to reduce representation in congress of the cotton states where a relatively high number of slaves lived, and to increase the representation of the northern states where relatively few slaves lived.
When the 3/5ths compromise was being debated slavery was legal in all states.
The record shows that of the 13 original states, 13 of them voted to enshrine slavery into the United States Constitution.
In 1787 slavery was outlawed in Massachusetts and was being gradually abolished in four other states.
In 1776 about half of Northern delegates who signed the Declaration of Independence owned slaves.
In 1787 none of the Northern delegates who signed the Constitution owned slaves.
But slaveholders did insist on protecting slavery in the Constitution as their price for supporting it.
Northerners in 1787 wanted Union more than abolition, just as they did in 1861.