Assuming the ids in the first table do identify the pairs, you can just do aggregation:
select id,
max(case when header = 'firstname' then value end) as firstname,
max(case when header = 'lastname' then value end) as lastname
from t
group by id;