Through strict requirements like these, God impressed upon his people the seriousness of his holiness. The underlying reason for this warning on God’s part may well have been mercy. It was a mercy of God that he had made himself known to anyone; it was the continuing mercy of God that he did not destroy more persons more quickly because of their wickedness; and it was a condescending mercy of God that he presented himself in their midst. The revelation of God’s word brings with it demands, some of which seem harsh and difficult. But God is near. Some seem to be so judgmental; yet God has not destroyed all. Some seem to be so threatening; yet God by his mercy allows some sense of his presence to remain known in the camp. His manifestation is based on his mercy; his strictures allow his mercy to continue to be realized.
–NIV Bible Commentary