On why there was such a law in the first place, we would have to wait for a historian of the Principate to answer, as such a restriction was already in place since the time of Augustus. However, I hope that I can provide some sixth-century context for this unique edict.
First all, it is important to note that the existing law was not repealed. Rather, this new edict opened a pathway for former actresses to marry imperial officials, as once they had abandoned their career, they could now petition the emperor for the right to a legitimate marriage. So yes, this was a law issued around 523 to allow Justinian to marry Theodora, but it was in fact far more specific than that, as it was only applicable to former actresses who had somehow managed to convince the emperor or the court that they have truly 'reformed'. As a result, this legislation cannot have affected too many people and was certainly not an attempt to rollback centuries of Roman tradition on this issue. By this stage, Theodora was an established person at court, had long abandoned her previous career, and had already been the mistress of an imperial official in Libya, so she was a very different person from an average actress and no doubt only one of a few who could actually take advantage of the new law. Historians have therefore suggested, quite rightly I think, that this was an edict that was specifically aimed at correcting Theodora's legal position, rather than a more general reform. We can, for instance, point also to an additional provision for daughters of former actresses - rather than children. As Theodora did have a daughter at this point, it would suggest that this edict was indeed meant to be a very narrow one.
As some of the removed comments have suggested that this law was needed because an actress was equivalent to a prostitute, I need to add that whilst actresses were often painted as prostitutes in literary sources, late Roman law was careful to distinguish between the two, and the law for former prostitutes was definitely more restrictive, so it would suggest that what was problematic about Theodora's past was that she was once a actress, not that she was a prostitute. The most well-known source for Theodora's scandalous earlier career is Procopius' Secret History, the purpose of which was to defame Justinian and Theodora, so we have to be very careful about trusting its account of Theodora's life. It is true that the more favourable John of Ephesus also said that Theodora came from a porneion, which meant brothel in Classical Greek, but in a different context Justinian decreed that performers of comedies, tragedies and other theatrical performances from a porneion should march together in a procession - which suggests that in a sixth-century context a porneion also referred to a theatre. There is no doubt that Theodora's career was rather scandalous compared to most of the empresses whom we know about (though the previous empress, Euphemia, was actually an ex-slave), but we have to tread carefully when exploring the available sources. At the very least, we should not trust Procopius' deeply negative account, as he had no intention of writing about the empress favourably or, indeed, truthfully.